﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x02000038 RID: 56
	public class NullableUInt16Formatter : IMessagePackFormatter<ushort?>
	{
		// Token: 0x060000CF RID: 207 RVA: 0x00004264 File Offset: 0x00002664
		private NullableUInt16Formatter()
		{
		}

		// Token: 0x060000D0 RID: 208 RVA: 0x0000426C File Offset: 0x0000266C
		public int Serialize(ref byte[] bytes, int offset, ushort? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteUInt16(ref bytes, offset, value.Value);
		}

		// Token: 0x060000D1 RID: 209 RVA: 0x00004294 File Offset: 0x00002694
		public ushort? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new ushort?(MessagePackBinary.ReadUInt16(bytes, offset, out readSize));
		}

		// Token: 0x0400002C RID: 44
		public static readonly NullableUInt16Formatter Instance = new NullableUInt16Formatter();
	}
}
